package com.ota.client;

import com.ota.client.api.*;
import com.ota.client.impl.FirmwareDownloader;
import com.ota.client.tools.Formater;

public class OTAApplication {
    public static void main(String[] args) {
        IFirmwareDownloader downloader = new FirmwareDownloader()
                .productId("PROD001")
                .serialNumber("DEV001")
                .server("https://70mm.cn/test")
                .key("your-secret-key-here")
                .tempDir("/tmp/ota")
                .timeout(600)
                .interval(5)
                .startWatch(new IUpgrate(){
                    String version = "1.0.0";

                    @Override
                    public void log(String format, Object... args) {
                        String str = Formater.format(format, args);
                        System.out.println(str);
                    }

                    @Override
                    public String version() {
                        //查询当前版本
                        return version;
                    }

                    @Override
                    public UpgrateInfo upgrade(String firmware, String version) {
                        log("开始升级：文件路径:{} ,version:{}",firmware,version);
                        //升级逻辑
                       return new UpgrateInfo(UpgradeStatus.COMPLETED,"更新成功");
                    }

                });
            
    }
}
